Skip to content

Bound Undo history growth after bulk edits - #1263

Merged
aiongg merged 1 commit into
storytold:mainfrom
derechopiano:fix/undo-memory-1227
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
derechopiano:fix/undo-memory-1227

Conversation

@derechopiano

@derechopiano derechopiano commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Repeated bulk formula edits could keep about 1.45 GB of old workbook snapshots alive because Undo stopped only at 100 steps. This change estimates the cell-band storage retained by each history step and removes the oldest steps once the estimated total exceeds 128 MiB. The newest edit always remains undoable, and ordinary small edits can still use the full 100-step history.

The estimate accounts for copy-on-write bands, formulas, and cell values; it is a history budget, not a hard cap on process memory. Undo and Redo use the same trimming policy. No UI behavior or file format changes are involved.

Fixes #1227.

Validation (updated 14 October 2026 for commit 72db972de306a165af5296cb2e5f932a19c0cc02):

  • cargo xtask ci passed locally on Windows: formatting, workspace Clippy, all workspace tests, assets, layering, WASM, parity, and keytips.
  • GitHub CI passed independently.

This PR was opened before the required full local suite had finished because the drive was short of space. That was premature. After resolving the storage blocker without removing the existing GridCraft build cache, I reran the complete local gate on the unchanged PR commit. The local test environment also needed a writable temporary directory and permission for a loopback-socket integration test; the final run completed successfully.

@aiongg
aiongg merged commit 43cd35d into storytold:main Oct 22, 2026
1 check passed
nihilist-narwhal added a commit to nihilist-narwhal/gridcraft that referenced this pull request Nov 2, 2026
The undo history drops its oldest steps past 100 entries or 128 MB of snapshots (storytold#1263). The
command-sequence fuzzer still compared "undo everything" with the episode's starting workbook,
so any episode whose snapshots passed the budget failed with "undoing all N steps doesn't give
back the starting workbook" although undo worked (seeds 104, 110 and 163 at 80 steps: a column
inserted next to whole-column borders, or rows deleted after filling whole columns, each made a
100 MB step).

The harness notices when an undoable command changed the workbook without the history growing,
and then compares with the state before the oldest step still in the history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skylartaylor pushed a commit that referenced this pull request Nov 18, 2026
* Fuzzer: undo checks follow the bounded undo history

The undo history drops its oldest steps past 100 entries or 128 MB of snapshots (#1263). The
command-sequence fuzzer still compared "undo everything" with the episode's starting workbook,
so any episode whose snapshots passed the budget failed with "undoing all N steps doesn't give
back the starting workbook" although undo worked (seeds 104, 110 and 163 at 80 steps: a column
inserted next to whole-column borders, or rows deleted after filling whole columns, each made a
100 MB step).

The harness notices when an undoable command changed the workbook without the history growing,
and then compares with the state before the oldest step still in the history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Fuzzer: undo and redo checks follow the reachable history boundary

Review of #2332. The harness now tracks the oldest state the undo history
can reach instead of a trimmed flag: whenever the history's oldest entry
changes without it emptying in between, the history dropped a step, and
undoing everything stops at the new oldest entry. That boundary is kept
when an edit.undo in the sequence uses up the retained history before the
episode ends, which used to fall back to the episode's start and report a
false undo mismatch.

The redo round trip no longer assumes n undos leave n redo entries: the
redo history is bounded too, so when it dropped the first step undone,
redo is expected to stop at the oldest entry it kept.

---------

Co-authored-by: nihilist-narwhal <240798405+nihilist-narwhal@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undo history keeps ~16 MB per bulk edit on a large sheet: ~1.45 GB for 100 steps on one workbook

2 participants